package com.hefu.virtuallife.ui.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hefu.virtuallife.R;
import com.hefu.virtuallife.ui.foods.bean.CollectionSellersBean;

import java.util.HashSet;
import java.util.Set;

/**
 * creat_user: zhengzaihong
 * Email:1096877329@qq.com
 * creat_date: 2018/8/13
 * creat_time: 13:34
 * describe 收藏的店铺
 **/

public class CollectionSellersAdapter extends BaseQuickAdapter<CollectionSellersBean, BaseViewHolder> {


    private Set<CollectionSellersBean> seleteds = new HashSet<>();

    public CollectionSellersAdapter() {
        super(R.layout.itme_fragment_seller_info);
    }

    /**
     * 添加到选中集合
     *
     * @param position
     */
    public void addSelected(CollectionSellersBean position) {
        seleteds.add(position);
    }

    public void removeSelected(CollectionSellersBean position) {
        if (seleteds.contains(position)) {
            seleteds.remove(position);
        }
    }

    /**
     * 清空选中集合
     */
    public void removeselected() {
        seleteds.clear();
        notifyDataSetChanged();
    }

    /*
     * 判读是否饱含当前的条目
     */
    public boolean isItemSelected(CollectionSellersBean position) {
        return seleteds.contains(position) ? true : false;
    }

    @Override
    protected void convert(BaseViewHolder holder, CollectionSellersBean shardAllBean) {
   /*     if (seleteds.contains(shardAllBean)) {
            ((ImageView) holder.getView(R.id.cb_ischeck)).setImageResource(R.drawable.ic_qunfa_gouxuan);
        } else {
            ((ImageView) holder.getView(R.id.cb_ischeck)).setImageResource(R.drawable.ic_qunfa_weigouxuan);
        }*/

  /*      holder.setText(R.id.tv_price, shardAllBean.getPrice_after_coupons())
                .setText(R.id.tv_lessmoney, "立减" + shardAllBean.getPrice_coupons() + "元")
                .setText(R.id.tv_goodsdis, shardAllBean.getGoods_name());

        Glide.with(mContext).load(shardAllBean.getPic()).asBitmap()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .placeholder(R.drawable.pre_default)
                .into((ImageView) holder.getView(R.id.iv_goods));*/
    }


    private CheckListenner listenner;

    public void setCheckListenner(CheckListenner listenner) {
        this.listenner = listenner;
    }

    public interface CheckListenner {
        void callBack(Set<CollectionSellersBean> data);
    }
}
